﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tracy.DataModel;
using System.Xml;

namespace Tracy
{
    public class FormatProvider
    {
        List<Format> _formats = new List<Format>();

        public List<Format> Formats
        {
            get { return _formats; }
        }

        Dictionary<string, Format> _indexName = new Dictionary<string, Format>();
        public Format GetItem(string name)
        {
            if(_indexName.ContainsKey(name))
                return _indexName[name];
            return null;
        }

        public FormatProvider()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(@"Settings\Formats.xml");
            foreach(XmlElement formatNode in doc.SelectNodes("formats/format")){
                Format format = new Format(formatNode);
                Formats.Add(format);
                _indexName.Add(format.Name, format);
            }
        }
    }
}
